<?
	function parse_group($url)
	{
		global $root;
		$url = str_replace(' ', '%20', $url);

		$dom = file_get_html($url);

		$td_selector = '.mblock';

		$wrapper = $dom->find($td_selector);
		$wrapper = $wrapper[0];

		$table = $wrapper->find('table');
		$table = $table[0];

		$u = parse_url($url);
		$params = $u['query'];
		$pair_ar = explode('&', $params);
		$url_p = array();
		foreach ($pair_ar as $key => $value) {
			$t = explode('=', $value);
			$url_p[$t[0]] = $t[1];
		}

		$parts = array();
		
		$src = iconv('windows-1251', 'utf-8', $root.'/img.php?cat='.$url_p['cat'].'&mfg='.$url_p['mfg'].'&year='.$url_p['year'].'&group='.$url_p['group'].'&section='.$url_p['section']);
		$dest = 'img/'.$url_p['section'].'.gif';		
		copy($src, $dest);
		$parts['img'] = $url_p['section'].'.gif';
		
		foreach ($table->find('tr') as $tr) {
			$counter = 1;
			$part = array();
		 	foreach ($tr->find('td') as $td) {
		 		if (!($input = $td->find('input')))
		 		{
		 			switch ($counter) {
		 				case 1:
		 					$part['pos'] = iconv('windows-1251', 'utf-8', $td->innertext);
		 				break;
		 				case 2:
		 					$part['num'] = iconv('windows-1251', 'utf-8', $td->innertext);
	 					break;
	 					case 3:
	 						$part['name'] = iconv('windows-1251', 'utf-8', $td->innertext);
		 				break;
		 			}
		 		}		 		
		 		$counter++;
		 	}
		 	if (count($part))
		 	{
		 		$parts['p'][] = $part;
		 	}
		 	unset($part);	 	
		}
		return $parts;			
	}